package com.hostmann.corejava;

import java.util.Objects;

public class Manager extends Employee {
    private double bonus;
    
    /**
     * This is Manager constructor.
     * @param aName the manager name
     * @param aSalary the manager salary
     * @param aBonus the manager bonus
     */
    public Manager (String aName, double aSalary, double aBonus) {
        super(aName, aSalary);
        bonus = aBonus;
    }
    
    public void setBonus(double aBonus) {
        bonus = aBonus;
    }
    
    public double getSalary () {
        double baseSalary = super.getSalary();
        baseSalary += bonus;
        System.out.println("this is Manager!");
        return baseSalary;
    }
    
    public String getDescription () {
        return String.format("Manager %s with a salary of $%.2f, bonus is $%.2f", super.getName(), super.getSalary(), bonus);
    }
    
    public boolean equals (Object otherObject) {
        if (! super.equals(otherObject)) return false;
        
        Manager other = (Manager) otherObject;
        
        return bonus == other.bonus;
    }
    
    public int hashCode () {
        return super.hashCode() + 17 * Objects.hash(bonus);
        
    }
    
    public String toString () {
        return super.toString() + "[bonus=" + bonus + "]";
    }
}
